#!/usr/bin/env bash

set -uexo pipefail

argc=$#

target_dir=''
if [ ${argc} -le 0 ]; then
    target_dir=${PWD}
else
    target_dir=$1
    mkdir -p "${target_dir}"
    cd "${target_dir}" || exit
    target_dir=${PWD} # 相对路径转化为绝对路径
    cd -
fi

self_path=$(
    cd "$(dirname $0)" || exit
    pwd
)

cd "${target_dir}"
git init "${target_dir}"
cp "${self_path}/.gitignore" "${target_dir}/.gitignore"
touch "${target_dir}/Readme.md"
curl --request GET -sL \
     --url 'http://www.wtfpl.net/txt/copying/' \
     --output "${target_dir}/LICENSE.txt"

#git config --local user.name
#git config --local user.email
#git remote add origin

git add .* -- *
git status
